package gui.layer;

import java.io.IOException;

/**
 * Class for the grass.
 * @author Sandra Mayer
 *
 */
public class GreenTiledLayer extends BaseLayer {

	public static final String FILENAME = "/grass.jpg";
	
	/**
	 * Constructor.
	 * @throws IOException IOException
	 */
	public GreenTiledLayer()
			throws IOException {
		super(BaseLayer.NROFCELLSHOR,
				BaseLayer.NROFCELLSVER, FILENAME,
				BaseLayer.SIZEOFCELL, BaseLayer.SIZEOFCELL);
		createBackground();
	}

	/**
	 * Creates the background of the game field.
	 *
	 */
	private void createBackground() {
		int[] cells = {
				1, 2, 3, 2, 3,
				2, 1, 2, 3, 1,
				1, 2, 2, 3, 1,
				2, 3, 3, 2, 2,
				1, 2, 1, 3, 2 };

		// set the background with the images
		for (int i = 0; i < cells.length; i++) {
			int column = i % NROFCELLSHOR;
			int row = (i - column) / NROFCELLSHOR;
			this.setCell(column, row, cells[i]);
		}

		// set the location of the background
		this.setPosition(GAME_ORIGIN_X, GAME_ORIGIN_Y);
	}
}
